package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"smart-health-platforms/pkg"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"
)

type RightsCollectionLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRightsCollectionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RightsCollectionLogic {
	return &RightsCollectionLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RightsCollectionLogic) RightsCollection(in *user.RightsCollectionRequest) (*user.RightsCollectionResponse, error) {
	err := dao.RightsCollection(int32(in.BenefitsId))
	if err != nil {
		pkg.Warn("权益领取失败")
		return nil, err
	}
	return &user.RightsCollectionResponse{
		Msg: "权益领取成功",
	}, nil
}
